<?php
/**
 * PsiFramework
 *
 * Php Simple Framework
 *
 * PHP version 5.3
 *
 * @category  PsiFramework.Plugins.Form.Classes.Util.Json.DAO
 * @package   PsiFramework.Plugins.Form.Classes.Util.Json.Elements
 * @author    Remi San <remi.san@gmail.com>
 * @copyright 2011 Remi San
 * @license   http://creativecommons.org/licenses/by/3.0/  Creative Commons CC BY 3.0
 * @version   SVN: <svn_id>
 * @link      http://www.psiframework.com/phpdoc/classes/db_\PsiFramework\Plugins\Form\Classes\Util\Json\Elements\JsonFormInput.html
 */

namespace PsiFramework\Plugins\Form\Classes\Util\Json\Elements;

import("Plugins.Form.Classes.Util.Json.JsonFormElement");
import("Plugins.Form.Classes.Util.Json.Elements.JsonFormOption");

use \PsiFramework\Plugins\Form\Classes\Util\Json\JsonFormElement;
use \PsiFramework\Plugins\Form\Classes\Util\Json\Elements\JsonFormOption;

/**
 * The json form input class
 *
 * This is the json form input model class
 *
 * @category PsiFramework.Plugins.Form.Classes.Util.Json.DAO
 * @package  PsiFramework.Plugins.Form.Classes.Util.Json.Elements
 * @author   Remi San <remi.san@gmail.com>
 * @license  http://creativecommons.org/licenses/by/3.0/  Creative Commons CC BY 3.0
 * @link     http://www.psiframework.com/phpdoc/classes/db_\PsiFramework\Plugins\Form\Classes\Util\Json\Elements\JsonFormInput.html
 */
class JsonFormInput extends JsonFormElement
{
    /**
     * @var string
     */
    protected /*string*/     $_inputType ;
    /**
     * @var string
     */
    protected /*string*/     $_name ;
    /**
     * @var array
     */
    protected /*array*/      $_options = array();
    /**
     * @var string
     */
    protected /*string*/     $_value ;
    /**
     * @var boolean
     */
    protected /*boolean*/    $_mandatory = false ;
    /**
     * @var boolean
     */
    protected /*boolean*/    $_string = true ;
    /**
     * @var boolean
     */
    protected /*boolean*/    $_numeric = false ;
    /**
     * @var boolean
     */
    protected /*boolean*/    $_float = false ;
    /**
     * @var boolean
     */
    protected /*boolean*/    $_displayAsImage = false ;
    /**
     * @var int
     */
    protected /*int*/        $_minLength ;
    /**
     * @var int
     */
    protected /*int*/        $_maxLength ;
    /**
     * @var bool
     */
    protected /*bool*/       $_image ;
    /**
     * @var int
     */
    protected /*int*/        $_imageWidth ;
    /**
     * @var int
     */
    protected /*int*/        $_imageHeight ;

    
    /**
     * Getter for input type
     * 
     * @return string
     */
    public function getInputType()
    {
        return $this->_inputType ;
    }

    /**
     * Setter for input type
     * 
     * @param string $inputType The input type
     * 
     * @return void
     */
    public function setInputType(/*string*/ $inputType)
    {
        $this->_inputType = $inputType ;
    }

    /**
     * Getter for name
     *
     * @return string
     */
    public function getName()
    {
        return $this->_name ;
    }

    /**
     * Setter for name
     *
     * @param string $name The name
     *
     * @return void
     */
    public function setName(/*string*/ $name)
    {
        $this->_name = $name ;
    }

    /**
     * Getter for options
     *
     * @return array
     */
    public function getOptions()
    {
        return $this->_options ;
    }

    /**
     * Setter for options
     *
     * @param array $options The options
     *
     * @return void
     */
    public function setOptions(/*array*/ $options)
    {
        $this->_options = $options ;
    }

    /**
     * The function to add an option
     * 
     * @param string $value The value
     * @param string $label The label
     * 
     * @return void
     */
    public function addOption(/*string*/ $value, /*string*/ $label)
    {
        if (isNullOrEmptyString($this->_options)) {
            if (is_null($this->_options)) {
                $this->_options = array();
            }
            $this->_options[$value] = $label ;
        }
    }

    /**
     * Getter for value
     *
     * @return string
     */
    public function getValue()
    {
        return $this->_value ;
    }

    /**
     * Setter for value
     *
     * @param string $value The value
     *
     * @return void
     */
    public function setValue(/*string*/ $value)
    {
        $this->_value = $value ;
    }

    /**
     * The function to add a value
     * 
     * @param string $value The value
     * 
     * @return void
     */
    public function addValue(/*string*/ $value)
    {
        if (isNullOrEmptyString($this->_value)) {
            if (!is_array($this->_value)) {
                $this->_value = array();
            }
            $this->_value[] = $value ;
        }
    }

    /**
     * Getter for mandatory
     *
     * @return bool
     */
    public function isMandatory()
    {
        return $this->_mandatory ;
    }

    /**
     * Setter for mandatory
     *
     * @param bool $mandatory Is the input mandatory ?
     *
     * @return void
     */
    public function setMandatory(/*bool*/ $mandatory)
    {
        $this->_mandatory = $mandatory ;
    }

    /**
     * Getter for min length
     *
     * @return int
     */
    public function getMinLength()
    {
        return $this->_minLength ;
    }

    /**
     * Setter for min length
     *
     * @param int $minLength The min length
     *
     * @return void
     */
    public function setMinLength(/*int*/ $minLength)
    {
        $this->_minLength = $minLength ;
    }

    /**
     * Getter for max length
     *
     * @return int
     */
    public function getMaxLength()
    {
        return $this->_maxLength ;
    }

    /**
     * Setter for max length
     *
     * @param int $maxLength The max length
     *
     * @return void
     */
    public function setMaxLength(/*int*/ $maxLength)
    {
        $this->_maxLength = $maxLength ;
    }

    /**
     * Getter for numeric
     *
     * @return bool
     */
    public function isNumeric()
    {
        return $this->_numeric ;
    }

    /**
     * Setter for numeric
     *
     * @param bool $numeric Is the input a numeric value ? 
     *
     * @return void
     */
    public function setNumeric(/*bool*/ $numeric)
    {
        $this->_numeric = $numeric ;
    }

    /**
     * Getter for float
     *
     * @return bool
     */
    public function isFloat()
    {
        return $this->_float ;
    }

    /**
     * Setter for float
     *
     * @param bool $float Is the input a float ?
     *
     * @return void
     */
    public function setFloat(/*bool*/ $float)
    {
        $this->_float = $float ;
    }
    
    /**
     * Getter for displayAsImage
     *
     * @return bool
     */
    public function isDisplayedAsImage()
    {
    	return $this->_displayAsImage ;
    }
    
    /**
     * Setter for displayAsImage
     *
     * @param bool $displayAsImage Is the input displayed as image ?
     *
     * @return void
     */
    public function setDisplayAsImage(/*bool*/ $displayAsImage)
    {
    	$this->_displayAsImage = $displayAsImage ;
    }

    /**
     * Getter for string
     *
     * @return bool
     */
    public function isString()
    {
        return $this->_string ;
    }

    /**
     * Setter for string
     *
     * @param bool $string Is the input a string ?
     *
     * @return void
     */
    public function setString(/*bool*/ $string)
    {
        $this->_string = $string ;
    }
    
    /**
     * Getter for image
     *
     * @return bool
     */
    public function isImage()
    {
    	return $this->_image ;
    }
    
    /**
     * Setter for image
     *
     * @param bool $image Is the file an image ?
     *
     * @return void
     */
    public function setImage(/*bool*/ $image)
    {
    	$this->_image = $image ;
    }
    
    /**
     * Getter for imageWidth
     *
     * @return int
     */
    public function getImageWidth()
    {
    	return $this->_imageWidth ;
    }
    
    /**
     * Setter for imageWidth
     *
     * @param int $imageWidth The image width
     *
     * @return void
     */
    public function setImageWidth(/*int*/ $imageWidth)
    {
    	$this->_imageWidth = $imageWidth ;
    }
    
    /**
     * Getter for imageHeigth
     *
     * @return int
     */
    public function getImageHeight()
    {
    	return $this->_imageHeight ;
    }
    
    /**
     * Setter for imageHeight
     *
     * @param int $imageHeight The image height
     *
     * @return void
     */
    public function setImageHeight(/*int*/ $imageHeight)
    {
    	$this->_imageHeight = $imageHeight ;
    }

}
